package com.dai.mq.config;

import com.dai.enu.RabbitmqEnum;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {

    //声明一个普通交换机
    @Bean
    public FanoutExchange fanoutExchangeOne() {
        return new FanoutExchange(RabbitmqEnum.GENERL_EXCHANGE);
    }
    //声明一个路由交换机
    @Bean
    public DirectExchange Direxchage(){
        return new DirectExchange(RabbitmqEnum.DIRECT_EXCHANGE);
    }

    //声明一个队列
    @Bean
    public Queue RabbitmqA1() {
        return new Queue(RabbitmqEnum.GENERL_QUEUE_ONE);
    }

    //绑定交换机和队列
    @Bean
    public Binding RabbitMqBiding(FanoutExchange fanoutExchangeOne, Queue RabbitmqA1) {
        return BindingBuilder.bind(RabbitmqA1).to(fanoutExchangeOne);
    }

    //声明一个队列
    @Bean
    public Queue RabbitmqA2() {
        return new Queue(RabbitmqEnum.GENERL_QUEUE_TWO);
    }

    //绑定交换机和队列
    @Bean
    public Binding RabbitMqBiding2(FanoutExchange fanoutExchangeOne, Queue RabbitmqA2) {
        return BindingBuilder.bind(RabbitmqA2).to(fanoutExchangeOne);
    }

    //声明一个队列rabbitmq
    @Bean
    public Queue rabbitmq() {
        return new Queue(RabbitmqEnum.GENERL_QUEUE_RABBITMQ);
    }

    @Bean
    public Queue fanout() {
        return new Queue("fanout");
    }
//声明一个路由队列
    @Bean
    public Queue DirectQueueOne(){
        return new Queue(RabbitmqEnum.QUEUE_DIRECT_ONE);
    }
    @Bean
    public Queue DirectQueueTwo(){
        return new Queue(RabbitmqEnum.QUEUE_DIRECT_TWO);
    }

}
